
<template>
  <div>
    {{ aDate }}
    <span class="componentB" @click="clickB">a组件</span>
  </div>
</template>

<script>
import bus from "../bus";

export default {
  data() {
    return {
      aDate: "组件A的值",
    };
  },
  created() {
    this.aBtn();
  },
  methods: {
    aBtn() {
      bus.$on("FunB", (message) => {
        //这里要用箭头函数，要不this指向有问题
        this.aDate = message;
      });
    },
    clickB() {
      this.aDate="组件A得值"
    },
  },
};
</script>
<style scoped>
.componentB {
  width: 200px;
  height: 100px;
  background: #000000;
  color: #ffffff;
  line-height: 100px;
  text-align: center;
  display: block;
}
</style>